package com.googlecode.jyoutubeuploader.to;

/**
 * @author tom
 *
 *	An immutable class that represents an argument key to compliment an argument value.
 */
public class ArgumentKey {

	private final String keyText;
	
	/**
	 * @param keyText	The text that this key represents
	 * @throws IllegalArgumentException	If keyText is 0 length or null 
	 */
	public ArgumentKey(String keyText) {
		if (keyText == null || keyText.length() == 0){
			throw new IllegalArgumentException("KeyText must not be null or 0 length");
		}
		this.keyText = keyText;
	}

	@Override
	public String toString() {
		return keyText;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((keyText == null) ? 0 : keyText.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ArgumentKey other = (ArgumentKey) obj;
		if (keyText == null) {
			if (other.keyText != null)
				return false;
		} else if (!keyText.equals(other.keyText))
			return false;
		return true;
	}
}
